﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Models
{
    public partial class wx_users
    {
        public string TypeStr
        {
            get
            {
                return Common.EnumHelper.Extentions.GetDescription(typeof(UserType), type);
            }
        }

        public int GetUserType()
        {
            try
            {
                if (id > 0)
                {
                    wx_usersLogic ul = new wx_usersLogic();
                    expertLogic el = new expertLogic();
                    var dbUser = ul.Getwx_users(id);
                    if (string.IsNullOrWhiteSpace(dbUser.mobile))
                    {
                        return (int)UserType.None;
                    }
                    else
                    {
                        var dbExpert = el.Getexpert(new expert { mobile = dbUser.mobile });
                        if (dbExpert == null)
                        {
                            return (int)UserType.Public;
                        }
                        else
                        {
                            return (int)UserType.Expert;
                        }
                    }

                }
                else
                {
                    return (int)UserType.None;
                }
            }
            catch (Exception)
            {
                return (int)UserType.None;
            }
        }
    }

    public enum UserType
    {
        [Description("未认证用户")]
        None = 0,
        [Description("大众")]
        Public = 1,
        [Description("专家")]
        Expert = 2
    }
}
